package com.test.springboot_test.stringTest;

import java.util.Arrays;

public class StringTest3 {
    public static void main(String[] args) {
        /**
         * 字符串的额基本操作
         * 1.字符串截取
         * 2.字符串拼接
         * 3.求字符串索引，匹配从前往后
         * 4.求字符串索引，匹配从后往前
         * 5.字母从大到小，字符串切换
         * 6.字母从小到大，字符串切换
         */
        //1.字符串截取、字符串索引
        String str = "1+1=@2";
        System.out.println(str.substring(0, str.lastIndexOf("@")));
        System.out.println(str.substring(str.lastIndexOf("@") + 1));
        //2.字符串拼接
        String str1[] = {"a","b","c"};
        StringBuilder builder = new StringBuilder();
        // 1
        Arrays.stream(str1).forEach(builder::append);
        System.out.println(builder.toString());
        // 2
        for(String a : str1){
            builder.append(a);
        }
        System.out.println(builder.toString());
    }

}
